1 // Copyright (C) 2024 Rubén Beltrán del Río
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see https://map.tranquil.systems.
17 struct MapNotes: View {
20 let lineWidth: CGFloat
26 ForEach(notes, id: \.id) { note in
27 Text(note.text.replacingOccurrences(of: "\\n", with: "\n")).font(.Theme.note)
30 .foregroundColor(.Map.labelColor)
31 .border(Color.Map.vertexColor, width: lineWidth)
32 .frame(minWidth: 16.0, maxWidth: maxWidth, alignment: .topLeading)
35 width: w(note.position.x),
36 height: h(note.position.y)
42 func h(_ dimension: CGFloat) -> CGFloat {
43 max(0.0, min(mapSize.height, dimension * mapSize.height / 100.0))
46 func w(_ dimension: CGFloat) -> CGFloat {
47 max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
53 mapSize: CGSize(width: 400.0, height: 400.0), lineWidth: 1.0,
56 id: 0, position: CGPoint(x: 50.0, y: 50.0),
58 "Notes can have a lot more text, so we need to make sure that they're resized correctly")